#include "sendmesitem.h"
#include "ui_sendmesitem.h"

sendmesitem::sendmesitem(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::sendmesitem)
{
    ui->setupUi(this);
    ui->mes->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    ui->mes->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}

sendmesitem::~sendmesitem()
{
    delete ui;
}

void sendmesitem::init(QString sa,QString ra,QString n, QString im, QString ti, QString me,bool ow)
{
    senderaccount=sa;
    receiveraccount=ra;
    name=n;
    image=im;
    time=ti;
    mes=me;
    own=ow;
    ui->time->setText(time);
    ui->name->setText(name);
    ui->mes->setPlainText(mes);
    ui->image->setIcon(QPixmap(image));
    if(own)
    {
        ui->mes->setStyleSheet("#mes{padding-left:3px;background-color:#0099ff;color:#d5eeff}");
    }
    else
    {
        ui->mes->setStyleSheet("#mes{padding-left:3px;background-color:#ffffff;color:black}");
    }
    ui->mes->setEnabled(false);
}
